<template>
  <el-dropdown @command="changeLanguage">
    <div>
      <svg-icon icon-class="language" style="color:#fff;font-size:20px" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="$i18n.locale==='zh'">中文</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="$i18n.locale==='en'">English</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  methods: {
    changeLanguage(type) { // 下拉菜单项的触发事件
      Cookie.set('language', type) // 存入cookie 刷新网页也不会改变语言
      this.$i18n.locale = type // i18n
    }
  }
}
</script>

<style>

</style>
